/**
 * $Id: Genre.java 20 2006-09-16 20:32:08Z willi.w $
 */
package at.wwu.tunes2db.types;

import java.util.Hashtable;

import org.apache.log4j.Logger;


/**
 * @author willi.w
 * Genre information
 */
public class Type extends Element {
    private static final Logger log = Logger.getLogger(Type.class.getName());

    private static final Hashtable<String, Type> types = new Hashtable<String, Type>();

    private Type(String new_name) {
        super(new_name);
    }

    public static Type add(String name) {
        
        if (types.containsKey(name.trim())) {
            instance = types.get(name.trim());
            instance.isNew = false;
        } else {
            instance = new Type(name.trim());
            instance.isNew = true;
            types.put(name.trim(), (Type) instance);
            log.debug("Type.add("+ (instance.isNew?"new ":"") + name + ")");
        }        
        return (Type) instance;
    }

    @Override
    public String toString() {
        return "Type " + id + ": " + name;
    }
}
